package com.clz.appdesign.myapp.ijkplayer;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.clz.appdesign.appdependence.base.BaseActivity;
import com.clz.appdesign.myapp.R;
import com.clz.appdesign.myapp.ijkplayer.media.IjkVideoView;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.jzvd.JZVideoPlayer;

/**
 * @author clz
 */
public class IjkPlayerActivity extends BaseActivity {

    private static final String VIDEO_URL = "http://jzvd.nathen.cn/342a5f7ef6124a4a8faf00e738b8bee4/cf6d9db0bd4d41f59d09ea0a81e918fd-5287d2089db37e62345123a1be272f8b.mp4";
    private static final String THUMB_IMAGE_URL = "https://api.youjuke.com/images/ask_expert/video_bg_05.png";
    @BindView(R.id.ijk_player)
    IjkVideoView mIjkPlayer;
    @BindView(R.id.videoplayer)
    JzVideoView mVideoplayer;

    @Override
    public void initToolbar() {
        ButterKnife.bind(this);
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }

    @Override
    public void doBusiness(Context mContext) {
        mVideoplayer.setUp(VIDEO_URL, JZVideoPlayer.SCREEN_WINDOW_NORMAL, "");
        Glide.with(this)
                .load(THUMB_IMAGE_URL)
                .centerCrop()
                .into(mVideoplayer.thumbImageView);
    }

    @Override
    public int layoutResID() {
        return R.layout.activity_ijk_player;
    }

    @Override
    public void onBackPressed() {
        if (JZVideoPlayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        JZVideoPlayer.releaseAllVideos();
    }
}
